package com.zhoug.androidlibapp;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.zhoug.androidlib.adapter.recycler.BaseRecyclerViewAdapter;
import com.zhoug.androidlib.adapter.recycler.BaseViewHolder;
import com.zhoug.androidlib.adapter.recycler.dividers.ListItemDecoration;
import com.zhoug.androidlib.base.AbsActivity;
import com.zhoug.androidlib.utils.Router;
import com.zhoug.androidlib.widget.dialog.gender.GenderChooser;
import com.zhoug.androidlib.widget.dialog.gender.IGenderChooser;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends AbsActivity implements BaseRecyclerViewAdapter.OnItemClickListener{
    private static final String TAG = ">>>MainActivity";
    private RecyclerView mRecyclerView;
    private Adapter mAdapter;

    private List<String> mData=Arrays.asList("选择性别","文件选择");

    @Override
    protected void setStatusBar() {
//        super.setStatusBar();
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_main;
    }

    protected void findViews() {
        mRecyclerView = findViewById(R.id.recyclerView);
    }

    @Override
    protected void addListener() {

    }

    @Override
    protected void onCreateFinish(@Nullable Bundle savedInstanceState) {
        mAdapter=new Adapter();
        mAdapter.setData(mData);
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.addItemDecoration(new ListItemDecoration(this,OrientationHelper.VERTICAL));
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    public void onItemClick(BaseRecyclerViewAdapter adapter, View view, int position) {
        switch (position){
            case 0:
                IGenderChooser genderChooser=new GenderChooser(this);
                genderChooser.setCancelable(true);
                genderChooser.setCallback(this::toastShort);
                genderChooser.show();
                break;
            case 1:
                Router.navigation(this,FileActivity.class );

                break;
            case 2:

                break;
            case 3:

                break;
            case 4:

                break;

        }
    }


    private class  Adapter extends BaseRecyclerViewAdapter<String>{

        @Override
        public int getLayoutId(int viewType) {
            return R.layout.main_list_item;
        }

        @Override
        public void onBindData(BaseViewHolder holder, String data, int position, int viewType) {
            if(data!=null){
                holder.setText(R.id.tv_label, data);
            }
        }
    }
}
